/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import type { ProColumns } from '@ant-design/pro-table';

const valueEnumArray: any = [
  [
    '-2',
    {
      text: '全部',
    },
  ],
  [
    '0',
    {
      text: '未审核',
    },
  ],
  [
    '1',
    {
      text: '已通过',
    },
  ],
  [
    '-1',
    {
      text: '未通过',
    },
  ],
];

const openPlatformEnumArray: any = [
  [
    '1',
    {
      text: '待审核',
    },
  ],
  [
    '2',
    {
      text: '已通过',
    },
  ],
  [
    '3',
    {
      text: '已拒绝',
    },
  ],
];

const openPlatformStatusEnumArray: any = [
  [
    '0',
    {
      text: '待审核',
    },
  ],
  [
    '1',
    {
      text: '已通过',
    },
  ],
  [
    '2',
    {
      text: '已拒绝',
    },
  ],
];

const invoiceTypeEnumArray: any = [
  [
    '',
    {
      text: '全部',
    },
  ],
  [
    '2',
    {
      text: '专用发票',
    },
  ],
  [
    '1',
    {
      text: '普通发票',
    },
  ],
];

const openPlatFormColumns = (formRef: any, type?: string) => {
  //examine
  const isExamine: boolean = type === 'examine';
  const columns: ProColumns[] = [
    {
      title: isExamine ? '开票状态' : '审核状态',
      dataIndex: isExamine ? 'status_invoice' : 'status',
      valueType: isExamine ? 'select' : 'radioButton',
      initialValue: isExamine ? '0' : '1',
      hideInTable: true,
      valueEnum: new Map<string, any>(
        isExamine ? openPlatformStatusEnumArray : openPlatformEnumArray,
      ),
      fieldProps: {
        onChange: () => formRef.current?.submit(),
      },
    },
    {
      title: '发票类型',
      dataIndex: 'type',
      valueType: 'select',
      initialValue: '',
      hideInTable: true,
      hideInSearch: !isExamine,
      valueEnum: new Map<string, any>(invoiceTypeEnumArray),
      fieldProps: {
        onChange: () => formRef.current?.submit(),
      },
    },
    {
      dataIndex: 'key_words',
      hideInTable: true,
      valueType: 'text',
      fieldProps: {
        placeholder: '输入账号/抬头搜索',
      },
      formItemProps: {
        name: 'key_words',
      },
    },
    {
      title: '申请日期',
      dataIndex: 'create_time',
      width: 150,
      search: false,
      align: 'center',
      ellipsis: true,
    },
    {
      title: '申请账户',
      dataIndex: 'phone',
      width: 140,
      search: false,
      align: 'center',
      ellipsis: true,
    },
    {
      title: 'app_id',
      dataIndex: 'app_id',
      width: 100,
      search: false,
      align: 'center',
      ellipsis: true,
    },
    {
      title: '开票抬头',
      dataIndex: 'invoice_title',
      width: 200,
      search: false,
      align: 'center',
      ellipsis: true,
    },
    {
      title: '转账日志号',
      dataIndex: 'bank_log_id',
      width: 100,
      search: false,
      hideInTable: isExamine,
      align: 'center',
      ellipsis: true,
    },
    {
      title: '申请金额',
      dataIndex: 'money',
      width: 100,
      search: false,
      align: 'center',
      ellipsis: true,
    },
    {
      title: '支付类型',
      dataIndex: 'pay_type',
      width: 100,
      search: false,
      align: 'center',
      ellipsis: true,
      valueEnum: {
        1: '支付宝',
        2: '微信',
        3: '银行转账',
      },
    },
    {
      title: '接口名称',
      dataIndex: 'api_name',
      width: 140,
      search: false,
      align: 'center',
      ellipsis: true,
    },
    {
      title: '套餐类型',
      dataIndex: 'buy_row',
      width: 160,
      search: false,
      align: 'center',
      ellipsis: true,
    },
    {
      title: '开票类型',
      dataIndex: 'type',
      width: 100,
      search: false,
      align: 'center',
      ellipsis: true,
      valueEnum: {
        1: '普通发票',
        2: '专用发票',
      },
    },
    {
      title: '电子邮箱',
      dataIndex: 'email',
      width: 160,
      search: false,
      align: 'center',
      ellipsis: true,
    },
  ];
  return columns;
};

export { valueEnumArray, openPlatformEnumArray, openPlatFormColumns };
